<!doctype html>
<html lang="zh">
	<head>
		<meta charset="UTF-8" />
		<title>登录</title>
		<meta name="viewport"
			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="css/mui.min.css" />
		<link rel="stylesheet" href="css/app.css" />
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<h1 class="mui-title">登录</h1>
		</header>
		<div class="mui-content">
			<form class="mui-input-group">
				<div class="mui-input-row">
					<label>用户名</label>
					<input id="user" type="text" class="mui-input-clear" placeholder="请输入用户名" value="xqk">
				</div>
				<div class="mui-input-row">
					<label>密码</label>
					<input id="pass" type="password" class="mui-password" placeholder="请输入密码" value="123456">
				</div>
			</form>
			<div style="margin: 0 10px;">
				<span>请阅读</span>
				<span id="xy" class="red">《协议》</span>
			</div>
			<div style="margin-top: 20px;">
				<button id="login" type="button" class="mui-btn mui-btn-blue mui-btn-block">登录</button>
			</div>
		</div>


		<script src="js/mui.js" type="text/javascript" charset="utf-8"></script>
		<script src="libs/request-1.js" type="text/javascript" charset="utf-8"></script>
		<script src="libs/common.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			mui.init()
			mui.plusReady(function() {
				main()
			})
			main()

			function main() {
				login()
				getSub('xy','xieyi')
			}

			function login() {
				document.getElementById('login').addEventListener('tap', function() {
					getLogin(Api.login.lg,JSON.stringify( {
						username: document.getElementById("user").value,
						password: document.getElementById("pass").value
					})).then(res => {
						if (res.code === 200) {
							localStorage.setItem('token', res.token)
							mui.toast('登陆成功')
							mui.openWindow('./index.html', 'index.html', {})
						} else {
							mui.toast('登陆失败')
						}
					})
				})
			}
		</script>
	</body>
</html>